from django.db import models
from django.utils import timezone as datetime


class User(models.Model):
    user_name = models.CharField(max_length=20, unique=True)  # 手机号
    pass_word = models.CharField(max_length=32, null=False, blank=False)  # 密码
    info = models.BooleanField(default=False)  # 报名信息

    examine_info = models.IntegerField(choices=((0, '审核未通过'), (1, '审核通过'), (2, '待审核')), default=2)  # 审核信息
    examine_time = models.DateTimeField(default=datetime.now)  # 审核时间
    examine_msg = models.CharField(max_length=30)  # 审核修改意见

    class Meta:
        db_table = 'user_info'
        verbose_name = '用户信息表'


class TeamData(models.Model):
    team_id = models.AutoField(primary_key=True)  # 主键

    teams_number = models.IntegerField()  # 队伍人数
    teams_name = models.CharField(max_length=20)  # 队伍名字
    submit_time = models.DateTimeField(default=datetime.now)  # 提交时间
    track = models.IntegerField(choices=((0, '高职高专本科'), (1, '研究生')))
    user_index = models.ForeignKey('User', on_delete=models.CASCADE)  # 外键

    class Meta:
        db_table = 'team_information'
        verbose_name = '队伍信息表'


class PeopleData(models.Model):
    people_id = models.AutoField(primary_key=True)  # 主键

    people_school = models.CharField(max_length=20)  # 学校
    people_name = models.CharField(max_length=20)  # 名字
    people_sex = models.IntegerField(choices=((0, '男'), (1, '女')))  # 性别
    people_email = models.CharField(max_length=32)  # 邮箱
    is_captain = models.IntegerField(choices=((0, '队员'), (1, '队长'), (2, '指导老师')), default=0)  # 身份
    id_card_id = models.IntegerField(default=0)  # 身份证id
    stu_id_card_id = models.IntegerField(default=0)  # 学生证id

    student_number = models.CharField(max_length=20)  # 学号
    id_number = models.CharField(max_length=18)  # 身份证号
    iphone_number = models.CharField(max_length=20)  # 手机号
    major = models.CharField(max_length=20)  # 专业

    nationality = models.CharField(max_length=20)  # 非中国籍信息
    nationality_type = models.CharField(max_length=20)  # 国籍

    team_index = models.ForeignKey('TeamData', on_delete=models.CASCADE)  # 外键

    class Meta:
        db_table = 'competition_information'
        verbose_name = '报名信息表'


class IdCard(models.Model):
    card_id = models.AutoField(primary_key=True)  # 主键

    file_id = models.CharField(max_length=32, default=0)  # 身份证图片名字

    class Meta:
        db_table = 'id_card_information'
        verbose_name = '身份证信息表'


class StudentIdCard(models.Model):
    student_card_id = models.AutoField(primary_key=True)  # 主键

    student_file_id = models.CharField(max_length=32, default=0)  # 学生证图片名字

    class Meta:
        db_table = 'student_id_card_information'
        verbose_name = '学生证信息表'
